feat(setup): copy wizard code blocks with c - #771
Open
ffantl-ld wants to merge 1 commit into
Open
Conversation
Code blocks are drawn with a left gutter bar, so selecting one by hand copies the gutter characters and the padding lipgloss squares the block off with. The wizard also owns the alternate screen, so the snippet is not in scrollback once it exits. Pressing c writes the raw content to the system clipboard with OSC 52, preferring the snippet over the install command when a screen shows both. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requirements
Related issues
REL-15243, under the CLI Onboarding Wizard A/B epic (REL-15183).
Stacked on #753, which introduces
cmd/setup.Describe the solution you've provided
ckeybinding at the wizard's final screen that copies the raw init snippet — or the install command, when there is no snippet — to the system clipboard via OSC 52wizardModelso tests assert the emitted sequence instead of writing to the terminalThe code block is drawn with a left gutter bar, so selecting it with the mouse copies the gutter characters and the padding lipgloss squares the block off with, and pasting that fails on every line. The wizard also runs in the alternate screen, so the snippet is not in scrollback once it exits — the copy has to happen while the TUI is live, which is exactly when the gutter is in the way.
Known limitation: OSC 52 support cannot be detected, and some terminals (including Apple Terminal) do not implement it. There,
creports success while the clipboard is untouched.Describe alternatives you've considered
Additional context
github.com/charmbracelet/x/ansimoves from an indirect to a direct dependency forSetSystemClipboard. It was already in the module graph via lipgloss; no new module is added.Testing approaches
cmd/setup/copy_test.go: the copied payload is byte-for-byte the raw snippet (asserted by decoding the OSC 52 base64, and by asserting the rendered view does contain the gutter bar the copy does not), snippet preferred over install command when both show, fallback to the command, no write on screens with nothing to copy, hint switches to confirmation, andcstill reaches the list filter while filtering.go build ./...,go vet,gofmt, andgo test ./...clean; 51 subtests incmd/setup;golangci-lintpassed via pre-commit.Note
Low Risk
Localized TUI keyboard handling and clipboard OSC output only; no auth, API, or persistence changes. Residual risk is UX-only where terminals without OSC 52 may show “copied” without updating the system clipboard.
Overview
Adds Press c to copy on the setup wizard’s final screen so users can grab init snippets or failed install commands without mouse-selecting gutter-decorated code blocks (alternate screen also hides scrollback).
Copy uses OSC 52 via
ansi.SetSystemClipboard, writing through an injectableclipboardwriter (os.Stdoutin production) so tests can assert the raw payload.copyableContentprefers the init snippet over the install command when both apply;copyHintswitches from “Press c…” to “Copied…” after a successful keypress.cis ignored when there’s nothing to copy and still passes through to list filtering likeqandh.Six tests in
copy_test.gocover OSC 52 encoding, preference/fallback, no-op cases, hint text, and filter behavior.github.com/charmbracelet/x/ansiis promoted to a directgo.moddependency.Reviewed by Cursor Bugbot for commit e4811aa. Bugbot is set up for automated code reviews on this repo. Configure here.